package com.ocean.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ocean.common.annotation.Log;
import com.ocean.common.enums.BusinessType;
import com.ocean.system.domain.TSLog;
import com.ocean.system.service.ITSLogService;
import com.ocean.common.core.controller.BaseController;
import com.ocean.common.core.domain.AjaxResult;
import com.ocean.common.utils.poi.ExcelUtil;
import com.ocean.common.core.page.TableDataInfo;

/**
 * 【请填写功能名称】Controller
 * 
 * @author ocean
 * @date 2024-06-25
 */
@Controller
@RequestMapping("/system/logts")
public class TSLogController extends BaseController
{
    private String prefix = "system/logts";

    @Autowired
    private ITSLogService tSLogService;

    @RequiresPermissions("system:logts:view")
    @GetMapping()
    public String log()
    {
        return prefix + "/log";
    }

    /**
     * 查询【请填写功能名称】列表
     */
    @RequiresPermissions("system:logts:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TSLog tSLog)
    {
        startPage();
        List<TSLog> list = tSLogService.selectTSLogList(tSLog);
        return getDataTable(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @RequiresPermissions("system:logts:export")
    @Log(title = "【归档日志导出】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TSLog tSLog)
    {
        List<TSLog> list = tSLogService.selectTSLogList(tSLog);
        ExcelUtil<TSLog> util = new ExcelUtil<TSLog>(TSLog.class);
        return util.exportExcel(list, "【请填写功能名称】数据");
    }

    /**
     * 新增【请填写功能名称】
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存【请填写功能名称】
     */
    @RequiresPermissions("system:logts:add")
    @Log(title = "【归档日志添加】", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TSLog tSLog)
    {
        return toAjax(tSLogService.insertTSLog(tSLog));
    }

    @RequiresPermissions("system:logts:yjremove")
    @Log(title = "【一键清空】", businessType = BusinessType.INSERT)
    @PostMapping("/yjremove")
    @ResponseBody
    public AjaxResult yjremove()
    {
        return toAjax(tSLogService.yjremove());
    }


    /**
     * 修改【请填写功能名称】
     */
    @RequiresPermissions("system:logts:edit")
    @GetMapping("/edit/{ID}")
    public String edit(@PathVariable("ID") String ID, ModelMap mmap)
    {
        TSLog tSLog = tSLogService.selectTSLogByID(ID);
        mmap.put("tSLog", tSLog);
        return prefix + "/edit";
    }

    /**
     * 修改保存【请填写功能名称】
     */
    @RequiresPermissions("system:logts:edit")
    @Log(title = "【归档日志编辑】", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TSLog tSLog)
    {
        return toAjax(tSLogService.updateTSLog(tSLog));
    }

    /**
     * 删除【请填写功能名称】
     */
    @RequiresPermissions("system:logts:remove")
    @Log(title = "【归档日志删除】", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tSLogService.deleteTSLogByIDs(ids));
    }
}
